// KenEgozi.com - my blog engine
// This project is licensed under the MIT License
//
//Copyright (c) 2007, Ken Egozi
//
//Permission is hereby granted, free of charge, to any person obtaining a copy
//of this software and associated documentation files (the "Software"), to deal
//in the Software without restriction, including without limitation the rights
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:

//The above copyright notice and this permission notice shall be included in
//all copies or substantial portions of the Software.

//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//THE SOFTWARE.

using Castle.MonoRail.Framework;
using System.Collections;
using System.Collections.Generic;

namespace KenEgozi.Com.Weblog.Application
{
	/// <summary>
	/// Supply with typed access to the PropertyBag and Flash containers
	/// </summary>
	public static class Typed
	{
		private static IRailsEngineContext Context
		{
			get { return MonoRailHttpHandler.CurrentContext; }
		}

		private static Flash flash
		{
			get { return Context.CurrentController.Flash; }
		}
		private static IDictionary propertyBag
		{
			get { return Context.CurrentController.Flash; }
		}

		public static class PropertyBag
		{
			public static BlogRollEntry[] blogRoll
			{
				get { return propertyBag["blogRoll"] as BlogRollEntry[]; }
				set { propertyBag["blogRoll"] = value; }
			}
			public static string commenterName
			{
				get { return propertyBag["commenterName"] as string; }
				set { propertyBag["commenterName"] = value; }
			}
			public static string commenterEmail
			{
				get { return propertyBag["commenterEmail"] as string; }
				set { propertyBag["commenterEmail"] = value; }
			}
			public static string commenterHomepage
			{
				get { return propertyBag["commenterHomepage"] as string; }
				set { propertyBag["commenterHomepage"] = value; }
			}

			public static Comment comment
			{
				get { return propertyBag["comment"] as Comment; }
				set { propertyBag["comment"] = value; }
			}
			public static Post post
			{
				get { return propertyBag["post"] as Post; }
				set { propertyBag["post"] = value; }
			}
			public static IEnumerable<Post> posts
			{
				get { return propertyBag["posts"] as IEnumerable<Post>; }
				set { propertyBag["posts"] = value; }
			}
			public static IEnumerable<ArchiveEntry> archive
			{
				get { return propertyBag["archive"] as IEnumerable<ArchiveEntry>; }
				set { propertyBag["archive"] = value; }
			}
			public static IEnumerable<TagCloudEntry> tagCloud
			{
				get { return propertyBag["tagCloud"] as IEnumerable<TagCloudEntry>; }
				set { propertyBag["tagCloud"] = value; }
			}

			public static bool showComments
			{
				get { return (bool)propertyBag["showComments"]; }
				set { propertyBag["showComments"] = value; }
			}
		}
	}
}
